{extend name="index/index" /}

<!--main-->
{block name="main"}
<div class="main-content">
    <div class="breadcrumbs" id="breadcrumbs">
        <script type="text/javascript">
            try {
                ace.settings.check('breadcrumbs', 'fixed')
            } catch (e) {
            }
        </script>

        <ul class="breadcrumb">
            <li>
                <i class="icon-home home-icon"></i>
                <a href="#">Home</a>
            </li>

            <li>
                <a href="/role">用户权限分配</a>
            </li>
            <li class="active">权限分配</li>
        </ul><!-- .breadcrumb -->

        <!--<div class="nav-search" id="nav-search">-->
            <!--<form class="form-search">-->
								<!--<span class="input-icon">-->
									<!--<input type="text" placeholder="Search ..." class="nav-search-input"-->
                                           <!--id="nav-search-input" autocomplete="off"/>-->
									<!--<i class="icon-search nav-search-icon"></i>-->
								<!--</span>-->
            <!--</form>-->
        <!--</div>&lt;!&ndash; #nav-search &ndash;&gt;-->
    </div>

    <div class="page-content">
        <div class="page-header">
            <h1>
                用户
                <small>
                    <i class="icon-double-angle-right"></i>
                    权限列表
                </small>
            </h1>
        </div><!-- /.page-header -->

        <div class="row">
            <div class="col-xs-12">
                <!-- PAGE CONTENT BEGINS -->

                <div class="row">
                    <div class="col-xs-12">
                        <div class="table-responsive">
                            <table id="sample-table-2" class="table table-striped table-bordered table-hover">
                                <thead>
                                <tr>
                                    <th class="center">
                                        <label>
                                            <input type="checkbox" class="ace"/>
                                            <span class="lbl"></span>
                                        </label>
                                    </th>
                                    <th>编号</th>
                                    <th>姓名</th>
                                    <th class="hidden-480">角色</th>

                                    <th>
                                        <i class=" hidden-480"></i>
                                        可访问的控制器
                                    </th>
                                    <th class="hidden-480">可访问的方法</th>
                                    <th class="hidden-480">操作</th>
                                </tr>
                                </thead>

                                <tbody>
                                <!--tr-->

                                {volist name="list" id="v"}
                                <tr>
                                    <td class="center">
                                        <label>
                                            <input type="checkbox" class="ace"/>
                                            <span class="lbl"></span>
                                        </label>
                                    </td>

                                    <td>
                                       {$info.id}
                                    </td>
                                    <td>{$info.uname}</td>
                                    <td class="hidden-480">{$info.rname}</td>
                                    <td>{$v.controller}</td>

                                    <td class="hidden-480">
                                        <span class="label label-sm label-warning">
                                          {$v.method}
                                        </span>
                                    </td>

                                    <td>
                                      <a href="{:url('admin/role/index')}">返回上一页</a>
                                    </td>
                                </tr>
                                {/volist}

                                <!--endtr-->

                                </tbody>
                            </table>

                        </div>
                    </div>
                </div>


                <!--编辑的模态框-->
                <div id="modal-table" class="modal fade" tabindex="-1">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-header no-padding">

                                <div class="table-header">
                                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                                        <span class="white">&times;</span>
                                    </button>
                                    Results for "Latest Registered Domains
                                </div>
                            </div>

                            <div class="modal-body no-padding">
                                <table class="table table-striped table-bordered table-hover no-margin-bottom no-border-top">


                                    <!--<tbody>-->
                                    <!--<tr>-->
                                    <!--<td>-->
                                    <!--<a href="#">ace.com</a>-->
                                    <!--</td>-->
                                    <!--<td>$45</td>-->
                                    <!--<td>3,330</td>-->
                                    <!--<td>Feb 12</td>-->
                                    <!--</tr>-->

                                    <!--<tr>-->
                                    <!--<td>-->
                                    <!--<a href="#">base.com</a>-->
                                    <!--</td>-->
                                    <!--<td>$35</td>-->
                                    <!--<td>2,595</td>-->
                                    <!--<td>Feb 18</td>-->
                                    <!--</tr>-->

                                    <!--<tr>-->
                                    <!--<td>-->
                                    <!--<a href="#">max.com</a>-->
                                    <!--</td>-->
                                    <!--<td>$60</td>-->
                                    <!--<td>4,400</td>-->
                                    <!--<td>Mar 11</td>-->
                                    <!--</tr>-->

                                    <!--<tr>-->
                                    <!--<td>-->
                                    <!--<a href="#">best.com</a>-->
                                    <!--</td>-->
                                    <!--<td>$75</td>-->
                                    <!--<td>6,500</td>-->
                                    <!--<td>Apr 03</td>-->
                                    <!--</tr>-->

                                    <!--<tr>-->
                                    <!--<td>-->
                                    <!--<a href="#">pro.com</a>-->
                                    <!--</td>-->
                                    <!--<td>$55</td>-->
                                    <!--<td>4,250</td>-->
                                    <!--<td>Jan 21</td>-->
                                    <!--</tr>-->
                                    <!--</tbody>-->
                                </table>
                            </div>

                            <div class="modal-footer no-margin-top">
                                <button class="btn btn-sm btn-danger pull-left" data-dismiss="modal">
                                    <i class="icon-remove"></i>
                                    Close
                                </button>

                                <ul class="pagination pull-right no-margin">
                                    <li class="prev disabled">
                                        <a href="#">
                                            <i class="icon-double-angle-left"></i>
                                        </a>
                                    </li>

                                    <li class="active">
                                        <a href="#">1</a>
                                    </li>

                                    <li>
                                        <a href="#">2</a>
                                    </li>

                                    <li>
                                        <a href="#">3</a>
                                    </li>

                                    <li class="next">
                                        <a href="#">
                                            <i class="icon-double-angle-right"></i>
                                        </a>
                                    </li>
                                </ul>
                            </div>
                        </div><!-- /.modal-content -->
                    </div><!-- /.modal-dialog -->
                </div>
                <!--END编辑的模态框-->

                <!-- PAGE CONTENT ENDS -->
            </div><!-- /.col -->
        </div><!-- /.row -->
    </div><!-- /.page-content -->
</div><!-- /.main-content -->


</div><!-- /.main-container-inner -->

<a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
    <i class="icon-double-angle-up icon-only bigger-110"></i>
</a>
</div><!-- /.main-container -->


{/block}
<!-- basic scripts -->

<!--[if !IE]> -->

<script src="/static/admin/js/jquery.min.js"></script>

<!-- <![endif]-->

{block name="myjs" }
<!--[if IE]>
<script src="/static/admin/js/1.10.2/jquery.min.js"></script>
<![endif]-->

<!--[if !IE]> -->

<script type="text/javascript">
    window.jQuery || document.write("<script src='/static/admin/js/jquery-2.0.3.min.js'>" + "<" + "/script>");
</script>

<!-- <![endif]-->

<!--[if IE]>
<script type="text/javascript">
    window.jQuery || document.write("<script src='/static/admin/js/jquery-1.10.2.min.js'>" + "<" + "/script>");
</script>
<![endif]-->

<script type="text/javascript">
    if ("ontouchend" in document) document.write("<script src='/static/admin/js/jquery.mobile.custom.min.js'>" + "<" + "/script>");
</script>
<script src="/static/admin/js/bootstrap.min.js"></script>
<script src="/static/admin/js/typeahead-bs2.min.js"></script>

<!-- page specific plugin scripts -->

<script src="/static/admin/js/jquery.dataTables.min.js"></script>
<script src="/static/admin/js/jquery.dataTables.bootstrap.js"></script>

<!-- ace scripts -->

<script src="/static/admin/js/ace-elements.min.js"></script>
<script src="/static/admin/js/ace.min.js"></script>

<!-- inline scripts related to this page -->

<script type="text/javascript">

    //    $('.p-btn').click(function(){
    //        var p_id=$(this).attr('data-id');
    //        pAjax(p_id);
    //    });
    //
    //    function pAjax(id){
    //        $.ajax({
    //            type:'get',
    //            dataType:'json',
    //            url:'action/',
    //            data:{id:id},
    //            success:function(data) {
    //
    //                var table = document.getElementById('tab');
    //                for (var i = 0; i < data[0]; i++) {
    //            console.log(i);
    //            var index = table.rows.length;
    //            var tr = table.insertRow(index);
    //            // 给tr添加列(单元格)并写入内容
    //            tr.insertCell(0).innerHTML = id;
    //            tr.insertCell(1).innerHTML = data[2];
    //            tr.insertCell(2).innerHTML = data[3];
    //            tr.insertCell(3).innerHTML = data[0][i].controller;
    //            tr.insertCell(4).innerHTML = data[0][i].method;
    //        }
    //
    //                },
    //            error:function()
    //            {
    //            },
    //        });
    //    }

    //


    $('.show-btn').click(function(){
        var show_id=$(this).attr('data-id');
        showAjax(show_id);
    });

    function showAjax(id){
        $.ajax({
            type:'get',
            dataType:'json',
            url:'role/'+id,
            success:function(data){
                var obj=document.getElementById('select');
                obj.options.length=0;
                $('#pppp').val(id);
                for (var i = 0; i < data.role.length; i++) {
                    obj.options.add(new Option(data.role[i].name,i));
                }
                $(obj).change(function(){
                    var index=obj.selectedIndex+1;
                    $('#ppp').val(index);
                })


                if(data.status){
                    $('h4').html(data.title);
                    td1.innerHTML=data.num;
                    td2.innerHTML=data.info[0].uname;
                    td3.innerHTML=data.info[0].rname;
                    td4.innerHTML='权限';
                    var str=data.info[0].icon;
                    var pic = str.replace(/'/g,"");
                    $('.icon').attr({'src':pic+"?flag="+Math.random()});
                }else{
                    $('h4').html(data.title);
//                    $('.icon').attr(data.src);
                }

            },
            error:function(){


            },
        });
    }



    $('.edit-btn').click(function(){
        var edit_id=$(this).attr('data-id');
        updateAjax(edit_id);
    })

    function updateAjax(id){

        $.ajax({
            type:'post',
            dataType:'json',
            url:'role/'+id,
            data:{_method:'PUT'},
            success:function(data){


//                if(data.status){
//                    toastr.success(data.info);
//                    tr.remove();
//                }else{
//                    toastr.error(data.info,'警告');
//                }
            },
            error:function(){


            },
        });
    }


    jQuery(function ($) {
        var oTable1 = $('#sample-table-2').dataTable({
            "aoColumns": [
                {"bSortable": false},
                null, null, null, null, null,
                {"bSortable": false}
            ]
        });


        $('table th input:checkbox').on('click', function () {
            var that = this;
            $(this).closest('table').find('tr > td:first-child input:checkbox')
                .each(function () {
                    this.checked = that.checked;
                    $(this).closest('tr').toggleClass('selected');
                });

        });


        $('[data-rel="tooltip"]').tooltip({placement: tooltip_placement});
        function tooltip_placement(context, source) {
            var $source = $(source);
            var $parent = $source.closest('table')
            var off1 = $parent.offset();
            var w1 = $parent.width();

            var off2 = $source.offset();
            var w2 = $source.width();

            if (parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2)) return 'right';
            return 'left';
        }
    })

</script>
{/block}

<div style="display:none">
    <script src='http://v7.cnzz.com/stat.php?id=155540&web_id=155540' language='JavaScript' charset='gb2312'></script>
</div>
</body>
</html>
